<template>
	<view class="logoList-container">
		<view class="list" v-if="list&&list.length" >
			<view class="item" v-for="item in list" :key="item._id">
				<view class="left">
					<view class="name">金额：<text class="gold"> {{item.gold}}</text></view>
					<view class="time">{{types[item.type]}}时间：{{formatDateTime(item.createTime)}}</view>
				</view>
				<view class="type" :class="getTypeClass(item.type)">{{ types[item.type] }}</view>
			</view>

		</view>
		<view v-else class="empty">
			<image src="@/static/images/empty.png" mode="aspectFit" style="width: 100%;"></image>
		</view>
	</view>
</template>

<script>
	import {
		userLogList
	} from '@/api/user.js'
	import {
		formatDateTime
	} from '@/utils/timeTools.js'
	export default {
		data() {
			return {
				list: [],
				types: {
					1: '充值',
					2: '提现',
					3: '购买VIP',
					4: '其他',
				}
			}
		},
		onShow() {
			this.getUserLogList()
		},
		methods: {
			getUserLogList() {
				let user = JSON.parse(uni.getStorageSync('userInfo'))
				userLogList({
					_id: user._id
				}).then(res => {
					this.list = res.data || []
				})
			},
			getTypeClass(type) {
				switch (type) {
					case 1:
						return 'type-recharge';
					case 2:
						return 'type-withdraw';
					case 3:
						return 'type-vip';
					default:
						return 'type-other';
				}
			},
			formatDateTime
		},
	}
</script>

<style lang="scss" scoped>
	.logoList-container {
		padding: 20rpx;

		.empty {
			height: 500px;
			width: 100%;
		}

		.item {
			display: flex;
			justify-content: space-between;
			align-items: center;
			border: 2rpx solid rgba(0, 0, 0, 0.1);
			box-shadow: 0 5px 10px rgba(0, 0, 0, 0.1);
			padding: 20rpx;
			margin-bottom: 20rpx;
			border-radius: 10rpx;

			.type {
				border: 2rpx solid;
				color: var(--thorui-color-pink);
				border-radius: 8rpx;
				padding: 8rpx 20rpx;
				font-size: 26rpx;
			}

			.type-recharge {
				color: #07c160;
			}

			.type-withdraw {
				color: #007aff;
			}

			.type-vip {
				color: var(--thorui-color-pink);
			}

			.type-other {
				color: #ff7900;
			}

			.left {
				.name {
					font-size: 26rpx;
					color: #8a8a8a;
				}

				.gold {
					font-weight: bold;
					font-size: 40rpx;
					color: #383838;
				}

				.time {
					color: #8a8a8a;
					font-size: 24rpx;
					margin-top: 20rpx;
				}
			}
		}
	}
</style>